<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
include_once ("secure_area.php");

class Settings extends Secure_area {

	/**
	 * Index Page for this controller.
	 *
	 * Maps to the following URLa
	 * 		http://example.com/index.php/welcome
	 *	- or -
	 * 		http://example.com/index.php/welcome/index
	 *	- or -
	 * Since this controller is set as the default controller in
	 * config/routes.php, it's displayed at http://example.com/
	 *
	 * So any other public methods not prefixed with an underscore will
	 * map to /index.php/welcome/<method_name>
	 * @see http://codeigniter.com/user_guide/general/urls.html
	 */
	public function __construct(){

		parent::__construct();
	}

	public function index()
	{
		$data['title'] = 'Settings';
		$data['main_content'] = 'admin/settings';
		$this->load->view('admin/includes/template', $data);
	}

	//save/update config
	function save(){
		$batch_save_data=array(
		'emailfrom' => $this->input->post('emailfrom'),
		'fromname' => $this->input->post('fromname')
		);
		$this->load->model('Admin_settings_model');
		if( $this->Admin_settings_model->saveConfig() ){
			$this->message->set('success', 'Successfully save settings.');
		} else {
			$this->message->set('error', 'Failed to save settings');
		}
	}
}
